package top.ivansong92.example.leetcode.learning.data.struct.array;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String val = in.nextLine();
            if (val == null || val.length() == 0 || val.equals(" ")) {
                break;
            }
            System.out.println(parseLine(val));
        }
    }

    private static String parseLine(String string) {
        if (string == null || string.length() == 0) {
            return "";
        }
        Set<Character> filter = new HashSet<>();
        StringBuilder res = new StringBuilder();
        for(char ch : string.toCharArray()) {
            if (filter.contains(ch)) {
                continue;
            }
            res.append(ch);
            filter.add(ch);
        }
        return res.toString();
    }

    private static int doSolution(int n) {
        if (n == 1) {
            return n;
        }

        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = i;
        }

        int plus = n, counter = -1, index = 1;
        while (true) {
            if (plus == 1) {
                break;
            }

            counter++;
            if (array[counter % n] == -1) {
                continue;
            }

            if (index > 2) {
                array[counter % n] = -1;
                index = 1;
                plus--;
                continue;
            }
            index++;
        }

        for (int val : array) {
            if (val != -1) {
                return val;
            }
        }
        return 0;
    }


}